import 'package:flutter/material.dart';

class TextFieldPage extends StatefulWidget {
   TextFieldPage({super.key});

  @override
  State<TextFieldPage> createState() => _TextFieldPageState();
}

class _TextFieldPageState extends State<TextFieldPage> {
   late TextEditingController controller;

   @override
  void initState() {
    super.initState();
    controller = TextEditingController();
  }

  @override
  void dispose() {
    super.dispose();
    controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Text'),
      ),
      body: Padding(
        padding:  const EdgeInsets.all(20.0),
        child: ListView(

          children:  [
            const TextField(),
            const SizedBox(height: 16,),
            TextField(
              controller: controller,
              onChanged: (String value){print(value);},
              decoration: const InputDecoration(border: OutlineInputBorder(),prefixIcon: Icon(Icons.person),labelText: '请输入用户名'),),
            SizedBox(height: 16,),
            Row(

              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
              ElevatedButton(onPressed: (){
                print("登录：${controller.text}");
              }, child: Text("登录")),
              ElevatedButton(onPressed: (){}, child: Text("注册")),
            ],)
          ],
        ),
      ),
    );
  }
}
